﻿//-----------------------------------------------------------------------
// <copyright file="GroupBoxControlPage.cs" company="Noboru Project">
//      Copyright (c) Noboru Project. All rights reserved.
//
//      This source code is subject to terms and conditions of the New BSD License (BSD).
//      A copy of the license can be found in the License.html file at the root of this 
//      distribution. If you can not locate the New BSD License (BSD), please send an 
//      email to noboru_adm@live.com.
//      By using this source code in any fashion, you are agreeing to be bound by
//      the terms of the New BSD License (BSD) for Noboru.
//
//      You must not remove this notice, or any other, from this software.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Noboru.Demo
{
    public partial class GroupBoxControlPage : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the GroupBoxControlPage class.
        /// </summary>
        public GroupBoxControlPage()
        {
            this.InitializeComponent();
        }

        private void titleValue_TextChanged(object sender, TextChangedEventArgs e)
        {
            this.groupBoxTest.Title = ((TextBox)sender).Text;
        }

        private void widthValue_TextChanged(object sender, TextChangedEventArgs e)
        {
            double width;

            if (double.TryParse(((TextBox)sender).Text, out width))
            {
                if (width > 0)
                {
                    this.groupBoxTest.Width = width;
                }
            }
            else
            {
                this.groupBoxTest.Width = double.NaN;
            }
        }

        private void heightValue_TextChanged(object sender, TextChangedEventArgs e)
        {
            double height;

            if (double.TryParse(((TextBox)sender).Text, out height))
            {
                if (height > 0)
                {
                    this.groupBoxTest.Height = height;
                }
            }
            else
            {
                this.groupBoxTest.Height = double.NaN;
            }
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (this.groupBoxTest != null)
            {
                this.groupBoxTest.IsEnabled = ((CheckBox)sender).IsChecked.Value;
            }
        }

        private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            this.groupBoxTest.IsEnabled = ((CheckBox)sender).IsChecked.Value;
        }
    }
}
